package com.zsh.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Response1Servlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("resp1");
        //方法1
        //设置响应状态码
        //response.setStatus(302);

        //设置重定向地址,响应头设置
        //response.setHeader("Location","http://localhost:8080/07_servlet/r2");

        //方法2
        response.sendRedirect("http://localhost:8080/07_servlet/r2");
    }
}
